import App from './App'
// #ifndef VUE3
import Vue from 'vue'

import store from '@/store/index.js'
import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload)

import {
	$http
} from '@escook/request-miniprogram'

uni.$http = $http
$http.baseUrl = 'http://124.70.108.19:81/wsw'

$http.beforeRequest = function(options) {
	uni.showLoading({
		title: '数据加载中',
	})
	if (uni.getStorageSync('WSWUser')) {
		if (JSON.parse(uni.getStorageSync('WSWUser') || "")) {
			options.header.Cookie = JSON.parse(uni.getStorageSync('WSWUser'))
		}
	}

}

$http.afterRequest = function(options) {

	if (options.cookies.length != 0) {
		let cookie = options.cookies[0].split(';')[0]
		uni.setStorageSync('WSWUser', JSON.stringify(cookie))
	}

	uni.hideLoading()
}

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App,
	store
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
